package com.flexcodejam.vfd.model
{
	import com.flexcodejam.vfd.vo.ScoreBoard;
	import mx.collections.ArrayCollection;
	import com.flexcodejam.vfd.vo.User;
	import com.flexcodejam.vfd.vo.Organization;
	import com.flexcodejam.vfd.vo.FoodDrive;
	import mx.core.Application;
	import com.flexcodejam.vfd.vo.ApplicationState;
	
	public class VFDModelLocator {
		
		private static var modelLocator:VFDModelLocator;
		
		[Bindable]
      	public var scoreBoard:ScoreBoard;	
      	
      	[Bindable]
      	public var currentUser:User = new User();
		
		[Bindable]
		public var allFoodDrivesCollection:ArrayCollection;

		[Bindable]
		public var managerFoodDrivesCollection:ArrayCollection;
		
      	[Bindable]
      	public var FoodDriveView_CurrentFoodDrive:FoodDrive;
      	
      	[Bindable]
      	public var EditFoodDrive_CurrentFoodDrive:FoodDrive;
		
		[Bindable]
		public var states:ApplicationState = new ApplicationState();
		
      	//Actual ViewStackIndex
      	private var _currentViewStackIndex:int = -1;
      	
      	[Bindable]
      	public function get currentViewStackIndex():int{
      		if( _currentViewStackIndex == -1 ){
      			trace(Application.application.parameters.id);
      			if( Application.application.parameters.id != null 
      				&& Application.application.parameters.id.length > 0 
      				&& !isNaN(new Number(Application.application.parameters.id)) ){
      				return 1;// granny view
      			}else{
      				return 0;
      			}
      		}      		
      		return _currentViewStackIndex;
      	}
      	
      	
      	public function set currentViewStackIndex(i:int):void{
      		_currentViewStackIndex = i;
      	}
      	
      	
      	//super_User arrayCollections
      	
      	//All Organizations
	    [Bindable]
      	public var superUser_Organizations:ArrayCollection;
      	
      	//All Users
      	[Bindable]
      	public var superUser_Users:ArrayCollection;
      	
      	//All Food Drives - Report Format
      	[Bindable]
      	public var superUser_FoodDrives:ArrayCollection;
      
      	// Temporary EditFoodDrive variables
      	[Bindable]
      	public var editFoodDrive_User:User = new User();
      	
        
      	
      	//User CategoryArray
		[Bindable]
      	public var editFoodDrive_UserCategory:ArrayCollection;
      	
      	//NewFoodDrive - CurrentState
		[Bindable]
		public var editFoodDrive_CurrentState:String = "Login";
      	
		public function VFDModelLocator() {	
         	scoreBoard = new ScoreBoard();
      	}
		
		public static function getInstance():VFDModelLocator {
			if ( modelLocator == null ){
  				modelLocator = new VFDModelLocator();
  			}
  			return modelLocator;
		}
      
	}
}
class SingletonEnforcer{}
